<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加商品基本信息</title>
<script language="javascript">
	function saveform()
	{
		var tst = 0;
		var sku = $("#sku").val();
		if(sku=='')
		{
			alert("商品SKU必须填写");
			$("#sku").focus();
			return false;	
		}
		var inputArray=$("input[id='goods_name']");//取到所有的input text 并且放到一个数组中 
		inputArray.each(//使用数组的循环函数 循环这个input数组  
			 function (){  
				 var input =$(this);//循环中的每一个input元素  
				if(input.val()=="")
				{
					 tst =1;
				}
			 }  
		 )
		 if(tst==1)
		 {
			alert("所有的商品名称必须填写!");
			return false;	
		 }
		
		
		 
		 
		 
	
		 
	}
	function getcategorydata(id)
	{
		var value = $("#shopdatacate"+id).val();
		var txt= $("#shopdatacate"+id).find("option:selected").text();
		var tirmtxt = $.trim(txt);
		
		if($("#strcategorydata"+id).val())
		{
			var newtxt = $("#strcategorydata"+id).val()+","+tirmtxt;
		}else{
			var newtxt = 	tirmtxt;
		}
		if($("#strcategorydataid"+id).val())
		{
			var newtxtvalue = $("#strcategorydataid"+id).val()+","+value;
		}else{
			var newtxtvalue = 	value;
		}
		$("#strcategorydataid"+id).val(newtxtvalue);
		$("#strcategorydata"+id).val(newtxt);
	}

	function includingdata(id)
	{
		var txt= $("#includingdata"+id).find("option:selected").text();
		var value = $("#includingdata"+id).val();
		var tirmtxt = $.trim(txt);
		if($("#strincluding"+id).val())
		{
			var newtxt = $("#strincluding"+id).val()+","+tirmtxt;
		}else{
			var newtxt = 	tirmtxt;
		}
		if($("#includingdataid"+id).val())
		{
			var newtxtvalue = $("#includingdataid"+id).val()+","+value;
		}else{
			var newtxtvalue = 	value;
		}
		$("#includingdataid"+id).val(newtxtvalue);
		
		$("#strincluding"+id).val(newtxt);
	}
	
	
	function fabricdata(id)
	{
		var txt= $("#fabricdata"+id).find("option:selected").text();
		var value = $("#fabricdata"+id).val();
		
		var tirmtxt = $.trim(txt);
		if($("#strfabricdata"+id).val())
		{
			var newtxt = $("#strfabricdata"+id).val()+","+tirmtxt;
		}else{
			var newtxt = 	tirmtxt;
		}
		if($("#fabricdataid"+id).val())
		{
			var newtxtvalue = $("#fabricdataid"+id).val()+","+value;
		}else{
			var newtxtvalue = 	value;
		}
		$("#fabricdataid"+id).val(newtxtvalue);
		
		$("#strfabricdata"+id).val(newtxt);
	}
	function clearinput(id,txt,txt2)
	{
		$("#"+txt+id).val('');
		$("#"+txt2+id).val('');
	}
	function getSku()
	{
		var sku = $("#sku").val();
		if(sku){
			$.post("/product/ajaxbutton", {"op": "searchsku","sku":sku},function(data){
				if(data ==200)
				{
					 //alert("SKU不存在！");
					 //$("#sku").val('');
					//return false;
				}else{
					
						$("#skuerr").html('&nbsp;&nbsp;<font color=red><B>'+data.res.p_parent_name+'</B></font>');
						var inpit = Math.ceil(data.res.p_weight / 1000);
						
						strprice
						 
						 $("input[id='p_weight']").each(function(){       
							$(this).val(inpit);    
						});  
						 $("div [id=strprice]").each(function(){       
							$(this).html("成本("+data.res.p_costprice+") RMB");    
						});  
				
				}
			},"json");
		}
	}
	
	function getwebsku(web,o)
	{
		var sku = $("#sku").val();
		if(sku){
			$.post("/magento/ajaxbutton", {"op": "getwebsku","sku":sku,"webname":web},function(data){
				if(data ==200)
				{
					  alert(web+" SKU已经存在！");
					  var input =$(this);
					  o.value='';
					//return false;
				}
			},"json");
		}
	}
	

</script>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/leftmenu.tpl'}}
<div class="centercontent">
<div class="pageheader notab">
  <h1 class="pagetitle">二、添加商品基本信息</h1>
  <span class="pagedesc"></span>
  <div class="menulist"> </div>
</div>
<!--pageheader-->

<div id="contentwrapper" class="contentwrapper">
<div id="basicform" class="subcontent">
<form class="stdform stdform2"  id="otherForm" method="post" action="/magento/saveproductNext" enctype="multipart/form-data" >
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <thead>
      <tr>
        <th colspan="2" class="head1">一、商品SKU</th>
      </tr>
    </thead>
  </table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <tbody>
      <tr>
        <td class="head1" width="10%"><font color="#FF0000">商品SKU *</font></td>
        <td colspan="3" class="head0"><input type="text" name="sku" id="sku" class="width200" value="{{$goods.p_parent_sku}}" onKeyUp="this.value=this.value.replace(/[^\w_\w-]/g,'');" required style="text-transform:uppercase;" onChange="getSku()" >
          <span id="skuerr"></span></td>
      </tr>
    </tbody>
  </table>
    <table><tr><td height="15"></td></tr></table>

  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <thead>
      <tr>
        <th colspan="2" class="head1">二、商品名称</th>
      </tr>
    </thead>
  </table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <tbody>
    
    {{foreach from=$newshop item=li key=key}}
    <tr>
      <td class="head1" width="20%"><font color="#FF0000">【{{$li.webname}}】 商品名称</font></td>
      <td colspan="6" class="head0"><input type="text" name="goods_name[]" id="goods_name" class="width400" value="{{$goods.goods_name}}" onChange="getwebsku('{{$li.webname}}',this)" required>
      <input type="hidden" name="webname[]" id="webname" class="width400" value="{{$li.webname}}" required>
        <input type="hidden" name="shopid[]" id="shopid" class="width400" value="{{$li.id}}" required>
        <font color="#FF0000">*</font> 注意店铺语种 </td>
    </tr>
    {{/foreach}}
      </tbody>
    
  </table>
   <table><tr><td height="15"></td></tr></table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <thead>
      <tr>
        <th colspan="2" class="head1">三、分类选择</th>
      </tr>
    </thead>
  </table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <tbody>
    
    {{foreach from=$newshop item=li key=key}}
    <tr>
      <td class="head1" width="15%"><font color="#FF0000">请选择【{{$li.webname}}】分类</font></td>
      <td  class="head0"><input type="text" name="categorydata[]" class="width400" required id="strcategorydata{{$li.id}}"  readonly  placeholder="可以使用右侧下拉框多次选择分类">
        <input type="hidden" name="categorydataID[]" class="width400"  id="strcategorydataid{{$li.id}}" readonly >
        <img src="/fuman/images/trash.png" onClick="clearinput({{$li.id}},'strcategorydata','strcategorydataid')">
        <select  onChange="getcategorydata({{$li.id}})" id="shopdatacate{{$li.id}}"  class="selection select2_group">
          <option value="0">-店铺分类-</option>
          
              {{foreach from= $li.categorytree item = res key=key}}
                
          <option value="{{$key}}">{{$res.name}}</option>
          
             		{{if $res.child}}
                         {{foreach from=$res.child  item= chlids key=key}}
                          
          <option value="{{$key}}">&nbsp;&nbsp;{{$chlids.name}}</option>
          
                          	
                            {{if $chlids.child}}
                                 {{foreach from=$chlids.child  item= smallchlids key=key}}
                                  
          <option value="{{$key}}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{$smallchlids.name}}</option>
          
                                 {{/foreach}}
                            {{/if}}
                          
                          
                         {{/foreach}}
               		{{/if}}
                 {{/foreach}}
        
        </select>
        
       <a href="/magento/ajaxbutton?op=getcategorytree&shopid={{$li.id}}" target="_blank"> 如果没有分类请点击此处 </a>
        </td>
    </tr>
    {{/foreach}}
      </tbody>
    
  </table>
   <table><tr><td height="15"></td></tr></table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <thead>
      <tr>
        <th colspan="2" class="head1">四、价格和重量</th>
      </tr>
    </thead>
  </table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
  <tbody>
  
  {{foreach from=$newshop item=li key=key}}
  <tr>
    <td class="head1" width="15%"><font color="#FF0000">【{{$li.webname}}】 价格</font></td>
    <td  class="head0"><input type="text" name="price[]" class="width200" value="{{$goods.price}}" required>
      <div id="strprice"></div></td>
    <td class="head1" width="15%">【{{$li.webname}}】 折扣价格</td>
    <td  class="head0"><input type="text" name="special_price[]" class="width200" value="0" ></td>
    <td class="head1" width="15%"><font color="#FF0000">【{{$li.webname}}】 重量(KG)</font></td>
    <td  class="head0"><input type="text" name="weight[]" id="p_weight" class="width200" value="{{$goods.weight}}" required></td>
  </tr>
  {{/foreach}}
  </tbody>
  </table>
   <table><tr><td height="15"></td></tr></table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <thead>
      <tr>
        <th colspan="2" class="head1">五、其他信息</th>
      </tr>
    </thead>
  </table>
  <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
    <tbody>
    
    {{foreach from=$newshop item=li key=key}}
   
    <tr>
     <td class="head1" width="12%"><font color="#FF0000">【{{$li.webname}}】 属性值</font></td>
      <td  class="head0">
        <select name="attributedataID[]"  id="attributedata" required>
          <option value="0">-请选择-</option>
              {{foreach from= $li.productdata item = res key=key}}
          <option value="{{$key}}">{{$res}}</option>
                 {{/foreach}}
        </select></td>
    
      </td>
      <td class="head1" width="12%">【{{$li.webname}}】 Including</td>
      <td  class="head0"><input type="text" name="includingdata[]" class="width200"  id="strincluding{{$li.id}}"   placeholder="可以使用右侧下拉框多次选择">
        <input type="hidden" name="includingdataid[]" class="width400"  id="includingdataid{{$li.id}}" readonly >
        <img src="/fuman/images/trash.png" onClick="clearinput({{$li.id}},'strincluding','includingdataid')">
        <select  onChange="includingdata({{$li.id}})" id="includingdata{{$li.id}}"  class="selection select2_group">
          <option value="0">-请选择-</option>
              {{foreach from= $li.including item = res key=key}}
          <option value="{{$key}}">{{$res}}</option>
                 {{/foreach}}
        </select></td>
        
      <td class="head1" width="12%">【{{$li.webname}}】 fabric</td>
      <td  class="head0">
      <input type="text" name="fabricdata[]" class="width200"  id="strfabricdata{{$li.id}}"   placeholder="可以使用右侧下拉框多次选择">
      <input type="hidden" name="fabricdataid[]" class="width400"  id="fabricdataid{{$li.id}}" readonly >
       <img src="/fuman/images/trash.png" onClick="clearinput({{$li.id}},'strfabricdata','fabricdataid')">
        <select onChange="fabricdata({{$li.id}})" id="fabricdata{{$li.id}}"  class="selection select2_group">
          <option value="0">-请选择-</option>
              {{foreach from= $li.fabric item = res key=key}}
          <option value="{{$key}}">{{$res}}</option>
                 {{/foreach}}
        </select>
      
      </td>
    </tr>
    {{/foreach}}
    </tbody></table>
     <table><tr><td height="15"></td></tr></table>
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
      <thead>
        <tr>
          <th colspan="2" class="head1">六、相关产品  关联产品 (直接填写sku，以 | 分隔【英文状态】)</th>
        </tr>
      </thead>
    </table>
      <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
  <tbody>
  
  {{foreach from=$newshop item=li key=key}}
  <tr>
    <td class="head1" width="15%"><font color="#FF0000">【{{$li.webname}}】 相关产品</font></td>
    <td  class="head0"><input type="text" name="related[]" class="width200" value="{{$goods.related}}" required>
    <td class="head1" width="15%"><font color="#FF0000">【{{$li.webname}}】 关联产品</font></td>
    <td  class="head0"><input type="text" name="up_sell[]" class="width200" value="" ></td>
  </tr>
  {{/foreach}}
  </tbody>
  </table>

     <table><tr><td height="15"></td></tr></table>
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
      <thead>
        <tr>
          <th colspan="2" class="head1">七、商品介绍</th>
        </tr>
      </thead>
    </table>
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
      <tbody>
      
      {{foreach from=$newshop item=li key=key}}
      <tr>
        <td class="head1" width="15%">【{{$li.webname}}】短简介</td>
        <td  class="head0"><textarea name="short_description[]" cols="10" rows="6" required>{{$goods.short_description}}</textarea></td>
        <td class="head1" width="15%">【{{$li.webname}}】 Meta Title</td>
        <td  class="head0"><textarea name="meta_title[]" cols="10" rows="6">{{$goods.meta_title}}</textarea></td>
        <td class="head1" width="15%">【{{$li.webname}}】 keywords</td>
        <td  class="head0"><textarea name="meta_keywords[]" cols="10" rows="6">{{$goods.meta_keywords}}</textarea></td>
      </tr>
      {{/foreach}}
      
      
      {{foreach from=$newshop item=li key=key}}
      <tr>
        <td class="head1">【{{$li.webname}}】简介</td>
        <td colspan="5" class="head0"><textarea name="description[]" cols="10" rows="6">{{$goods.description}}</textarea></td>
      </tr>
      {{/foreach}}
      <tr>
        <td height="50" colspan="6">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="6"  class="head0"><button type="submit" class="btn btn-primary" onClick="saveform()" > 下一步 </button></td>
      </tr>
        </tbody>
      
    </table>
      </tbody>
    
  </table>
</form>
</body>
</html>